/**
 * 
 */
package com.jie.eclipse.pan.utils;

import java.lang.reflect.Constructor;

/**
 * @author yanjie
 *
 */
public class ObjectHelper {
	public static Object  newInstance(String className, Object[] args)  {
		try {
			Class newoneClass = Class.forName(className);
			if(args != null && args.length > 0 ){
				Class[] argsClass = new Class[args.length];
				for (int i = 0, j = args.length; i < j; i++) {
					argsClass[i] = args[i].getClass();
				}
				Constructor cons = newoneClass.getConstructor(argsClass);
				return cons.newInstance(args);
			}else{
				return newoneClass.newInstance();
			}
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
